<?php
$this->breadcrumbs = array(
	'凭证列表' => array(
		'index'
	),
	sprintf("%s-%s/%s", $model->tokenYear, $model->tokenMonth, $model->number),
);

if (Yii::app()->user->checkAccess('accountTokenManage')) {
	$this->userActions = array(
		array(
			'label' => '凭证列表',
			'url' => array(
				'index'
			)
		),
		array(
			'label' => '新建凭证',
			'url' => array(
				'create'
			)
		),
		array(
			'label' => '更新凭证',
			'url' => array(
				'update',
				'id' => $model->id
			)
		),
		array(
			'label' => '更新凭证内容',
			'url' => array(
				'updateItems',
				'id' => $model->id
			)
		),
		array(
			'label' => '删除凭证',
			'url' => '#',
			'linkOptions' => array(
				'submit' => array(
					'delete',
					'id' => $model->id
				),
				'confirm' => '确定要删除这张凭证么？'
			)
		),
		array(
			'label' => '管理凭证',
			'url' => array(
				'admin'
			)
		),
	);
}
$itemPerSection = 5;
$items = $model->items;
$pages = intval((count($items) - 1) / $itemPerSection) + 1;
$i = 0;
?>
<div class="account-token-view">
<?php
$stat = new stdClass();
$stat->credit=0;
$stat->debit=0;
for ($page = 0; $page < $pages; $page++) {
?>
	<?php $this
			->renderPartial('_tokenSection',
				array(
					'model' => $model,
					'items' => array_slice($items, $page * $itemPerSection, $itemPerSection),
					'page' => $page + 1,
					'pages' => $pages,
					'itemPerSection' => $itemPerSection,
					'stat' => $stat
				));
	?>
<?php } ?>
</div>
<?php 
if(Yii::app()->user->checkAccess('accountTokenManage')){
	$this
		->renderPartial('_attachMaterialExpense',
				array(
					'model' => $model,
				));
}
?>
